#ifndef PLAYBACKSDK_H
#define PLAYBACKSDK_H

#include <windows.h>


// typedef enum {
// 	AUDIOCODECID_PCM,
// 	AUDIOCODECID_ADPCM,
// 	AUDIOCODECID_AMRNB,
// 	AUDIOCODECID_AMRWB,
// 	AUDIOCODECID_G711,
// 	AUDIOCODECID_MP3,
// } AudioCodecId;

#ifdef __cplusplus
extern "C" {
#endif



typedef int PLAYBACKSESSION;
typedef int (__cdecl *DataProviderCallBack)(PLAYBACKSESSION session, LPVOID param, unsigned char *bufferPtr, UINT len);

#define DLLSPEC __declspec(dllimport)

DLLSPEC int __cdecl InitializePlaybackSdk();
DLLSPEC int __cdecl UninitializePlaybackSdk();

DLLSPEC PLAYBACKSESSION __cdecl CreateWindowsMediaFilePlayer(const char *filename);
DLLSPEC PLAYBACKSESSION __cdecl CreateH264FileStreamPlayer(const char *filename, UINT fps);
DLLSPEC PLAYBACKSESSION __cdecl CreateH264BitStreamPlayer(DataProviderCallBack dataProvider, UINT fps, LPVOID param);
DLLSPEC PLAYBACKSESSION __cdecl CreateH264BitStreamPlayerWithSize(DataProviderCallBack dataProvider, UINT width, UINT height, UINT fps, LPVOID param);
DLLSPEC PLAYBACKSESSION __cdecl CreateTn86StreamPlayer(DataProviderCallBack dataProvider, UINT width, UINT height, AudioCodecId audioCodecId, int nAudioChannels, int nAudioSampleRate, int nAudioBitsPerSample, LPVOID param, UINT cacheFrameNum);
DLLSPEC PLAYBACKSESSION __cdecl CreateYUV420Player(UINT width, UINT height, UINT fps);
DLLSPEC PLAYBACKSESSION __cdecl Create8004Player(UINT width, UINT height, UINT fps);
DLLSPEC void __cdecl ClosePlaybackSession(PLAYBACKSESSION session);
DLLSPEC void __cdecl CloseAllPlaybackSession();

DLLSPEC void __cdecl SetSyncPlayback(PLAYBACKSESSION session, bool syncPlayback);
DLLSPEC int __cdecl PlaybackTn86Frame(PLAYBACKSESSION session, BYTE *data, UINT len);
DLLSPEC int __cdecl Playback8004Frame(PLAYBACKSESSION session, BYTE *data, UINT len);
DLLSPEC int __cdecl PlaybackYuvFrame(PLAYBACKSESSION session, BYTE *data, UINT len);
DLLSPEC int __cdecl PlaybackMediaFrame(PLAYBACKSESSION session, BYTE *videoData, UINT videoSize, BYTE* audioData, UINT audioSize, BOOL bIFrame, unsigned long timeTick);
DLLSPEC int __cdecl EnableSoundPlay(PLAYBACKSESSION session, BOOL enable);
DLLSPEC int __cdecl GetSoundPlayVolume(PLAYBACKSESSION session, UINT *volume);
DLLSPEC int __cdecl SetSoundPlayVolume(PLAYBACKSESSION session, UINT volume);

DLLSPEC int __cdecl IsSessionPlaying(PLAYBACKSESSION session);
DLLSPEC int __cdecl SetOutputPosition(PLAYBACKSESSION session, HWND hwnd, int x, int y, int width, int height);
DLLSPEC int __cdecl StartPlayback(PLAYBACKSESSION session);
DLLSPEC void __cdecl StopPlayback(PLAYBACKSESSION session);
DLLSPEC void __cdecl PausePlayback(PLAYBACKSESSION session);
DLLSPEC int __cdecl SaveSnapShot(PLAYBACKSESSION session, const char *filename);
DLLSPEC int __cdecl GetSnapShot(PLAYBACKSESSION session, char *buf, UINT bufSize);
DLLSPEC int __cdecl GetSnapShotSize(PLAYBACKSESSION session);
DLLSPEC int __cdecl UpdateVideoWindow(PLAYBACKSESSION session);
DLLSPEC int __cdecl GetPlaybackBitrate(PLAYBACKSESSION session);
DLLSPEC int __cdecl GetTotalFrame(PLAYBACKSESSION session);
DLLSPEC int __cdecl GetActualFps(PLAYBACKSESSION session);
DLLSPEC int __cdecl SetDisplayRect(PLAYBACKSESSION session, const RECT *rect);
DLLSPEC int __cdecl SetPlaybackRate(PLAYBACKSESSION session, double rate);

//for file play only
DLLSPEC int __cdecl GetFileTotalPlayTime(PLAYBACKSESSION session, DWORD *milliseconds);
DLLSPEC int __cdecl GetFileCurrPlayTime(PLAYBACKSESSION session, DWORD *milliseconds);
DLLSPEC int __cdecl SeekToPosition(PLAYBACKSESSION session, DWORD position);


typedef long (CALLBACK *DRAWCALLBACK)(PLAYBACKSESSION session, HDC hdc, long lParam);
typedef long (CALLBACK *DECODECALLBACK)(PLAYBACKSESSION session, char * buf, long  size, long width, long height, long stride, long lParam);

DLLSPEC int __cdecl GetActualVideoSize(PLAYBACKSESSION session, int *width, int *height);
DLLSPEC int __cdecl SetDrawCallback(PLAYBACKSESSION session, DRAWCALLBACK drawCallback, long param);
DLLSPEC int __cdecl SetDecodeCallback(PLAYBACKSESSION session, DECODECALLBACK decodeCallback, long param, int needDisplay);
DLLSPEC int __cdecl ChangePlaybackFps(PLAYBACKSESSION session, UINT fps);

//added by liulz,in 2008-12-05,callback after video window repainted,use may need redraw something on video.
typedef long (CALLBACK *VIDEOWNDPAINTCALLBACK)(PLAYBACKSESSION session, HWND hwnd, long lParam);
DLLSPEC int __cdecl SetVideoWindowPaintCallback(PLAYBACKSESSION session, VIDEOWNDPAINTCALLBACK callback, long param);

typedef long(CALLBACK *FrameCALLBACK)(PLAYBACKSESSION session, char * buf, long  size, long lParam );
DLLSPEC int __cdecl SetFrameCALLBACK(PLAYBACKSESSION session, FrameCALLBACK callback, long param);

#ifdef __cplusplus
}
#endif


#endif 
